﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ManageUser_edit.aspx.cs" Inherits="Com.CMS263.Web.manage.ManageUser_edit" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>         
    <link href="../style/main.css" rel="stylesheet" type="text/css" />
    <link href="../common/validator.css" rel="stylesheet" type="text/css" />

    <script src="../../js/jquery-1.4.2.min.js" type="text/javascript"></script>
    <script src="../../js/common.js" type="text/javascript"></script>
    <script type="text/javascript">
        function CheckUserName(name) {
            var username = document.getElementById(name.id);
            var lbl = document.getElementById("lblusername");
            lbl.style.display = "none";
            if (!isEmpty(username.value)) {
                if (!(username.value.length >= 2 && username.value.length <=16)) {
                    lbl.style.display = "inline";
                    lbl.innerHTML = "长度介于2-16个字符.";
                    return false;
                }
                else {
                
                    return true;
                }
            }
            else {
                lbl.style.display = "inline";
                lbl.innerHTML = "必填*";
                return false
            }
        }
        function CheckPhone(phone) {
            var lbl = document.getElementById("lblphone");
            lbl.style.display = "none";
            if (!isEmpty(phone.value)) {
                if (!isMobile(phone.value)) {
                    lbl.style.display = "inline";
                    lbl.innerHTML = "手机号码格式不正确!";
                    return false;
                }
                else
                {return true;}
            }
            else {
                lbl.style.display = "inline";
                lbl.innerHTML = "必填*";
                return false;
            }
        }
        function CheckNums(num) {
            var reg = new RegExp("^(([\\d]+)[\.]([\\d]{2}))$");
            var lbl = document.getElementById("lbl" + num.id);
            lbl.style.display = "none";
            if (!reg.test(num.value)) {
                lbl.style.display = "inline";
                lbl.innerHTML = "格式为:20.00";
                return false;
            }
            return true;
        }

        function useredit() {
            var rePwd = document.getElementById("repassword");
            var pwd = document.getElementById("password");
            var isrepwd = CheckPass(pwd);
            var isPwd = CheckRepassword(rePwd);
        
            var username=document.getElementById("username");
            var phone = document.getElementById("phone");
            var ischeck = document.getElementById("yes");
            var bananlce = document.getElementById("banance");       ;
            var ischeckusername = CheckUserName(username);
            var ischeckphone = CheckPhone(phone);
            var isnum = CheckNums(bananlce);       
            var user="<%=guest.UserName%>";
            var ph = "<%=guest.MobilePhone %>";
            var checkstate = "<%=guest.State %>";
            var banan = "<%=guest.Balance %>";

            var checknum = 0;
            if (ischeck.checked) {
                checknum = 1;
            }
            if (user == username.value && ph == phone.value && checkstate == checknum&&banan==bananlce.value) {
               alert("请改动数据!");
                return false;
            }
            else {
                if (ischeckusername && isnum && ischeckphone&&isPwd == true && isrepwd == true) {
                    form1.submit();
                            return true;
                        }
                        else {
                            alert('请注意数据的格式!');
                            return false;
                        }
            }
        }
        function CheckIsNull(val) {
            var txt = document.getElementById(val.id).value;
            var lblError = document.getElementById("lbl" + val.id);
            var ispass = false;
            if (txt == null || txt == "") {
                lblError.innerHTML = "必填*";
                //val.focus();
                ispass = false;
            }
            else {
                lblError.style.display = "none";
                ispass = true;
            }
            return ispass;
        }
        function CheckPass(txt) {
            var ispass = CheckIsNull(txt);
            var pass = false;
            if (ispass) {
                var password = document.getElementById(txt.id).value;
                var reg = new RegExp("^([\\w]{6,20})$");
                var lblpassword = document.getElementById("lbl" + txt.id);
                lblpassword.style.display = "inline";
                if (!reg.test(password)) {
                    lblpassword.innerHTML = "只能为英文，字母和数字,并最少6位";

                    pass = false;
                }
                else {
                    lblpassword.style.display = "none";
                    pass = true;
                }

            }
            //        txt.blur();
            //        txt.focus();
            return pass;
        }
        function CheckRepassword(txt) {
            var isnull = CheckIsNull(txt);
            var ispass = false;
            if (isnull) {
                var repassword = document.getElementById(txt.id).value;
                var lblrepassword = document.getElementById("lbl" + txt.id);
                if (CheckPass(txt)) {
                    var password = document.getElementById("password").value;
                    lblrepassword.style.display = "inline";
                    if (password == txt.value) {
                        lblrepassword.style.display = "none";
                        ispass = true;
                    }
                    else {
                        lblrepassword.innerHTML = "两次输入的密码不一致!";
                        ispass = false;
                    }
                }
            }
            //        txt.blur();
            //        txt.focus();
            return ispass;
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
 <table width="96%" border="0" align="center" cellpadding="0" cellspacing="0" class="table_1">
            <tr>
                <td height="23" class="table_2" colspan="2">
                    用户管理
                </td>
            </tr>
            <tr>
          <td class="tdside" colspan="2">
            修改用户</td>
              </tr>
            <tr>
                 <td class="tdside" style=" width:100px; text-align:center;">
                  
                     邮&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 箱:</td><td class="tdside"><input id="email"  type="text" name="email" value="<%=guest.UserEmail %>"  readonly="readonly" /><span id="lblemail" style="color:Red"></span></td>
            </tr>
            <tr>
                 <td class="tdside" style=" width:100px; text-align:center;">
                  
                     用&nbsp;&nbsp;&nbsp; 户&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 名:</td><td class="tdside"><input id="username" name="username" type="text" value="<%=guest.UserName %>" onblur="CheckUserName(this)" /><span id="lblusername" style="color:Red"></span></td>
            </tr>
              <tr>
                 <td class="tdside" style=" width:100px; text-align:center;">
                   
           密&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;码:</td><td class="tdside"><span class="CL_mr">
                <input type="password" class="pwd" id="password" name="userpassword" onblur="CheckPass(this)"
                    tabindex="2" /><span id="lblpassword" style="color: Red"></span></span>
                     <%--密&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 码:</td><td class="tdside"><input id="password"  type="text" name="password"/><span style="color:red" id="passwordSpan"></span>--%></td>
           <td><%--<span id="StateSpan"></span>--%><span  style="height: 18px; font-size: 12px; line-height: 18px;">
                最多16个字符，只能为英文，字母和数字</span></td>
            </tr>        
             <tr>
                 <td class="tdside" style=" width:100px; text-align:center;">
                   
           确&nbsp;&nbsp;认&nbsp;&nbsp;密&nbsp;&nbsp;码:</td><td class="tdside">
                 <input type="password"id="repassword" onblur="CheckRepassword(this)"  tabindex="3" /><span id="lblrepassword" style="color: Red"></span>
                     <%--密&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 码:</td><td class="tdside"><input id="password"  type="text" name="password"/><span style="color:red" id="passwordSpan"></span>--%></td>
           <td><span  style="height: 18px; font-size: 12px; line-height: 18px;">
                最少为6位</span></td>
            </tr>    
            <tr>
                 <td class="tdside" style=" width:100px; text-align:center;">
                  
                     注&nbsp; 册&nbsp; 日&nbsp; 期:</td><td class="tdside"><%=guest.AddDate %></td></tr>
                       <tr>
                 <td class="tdside" style=" width:100px; text-align:center;">
                  
                     手&nbsp; 机&nbsp; 号&nbsp; 码:</td><td class="tdside"><input id="phone" name="phone" type="text" value="<%=(guest.MobilePhone!="-1"?guest.MobilePhone:"" )%>" onblur="CheckPhone(this)" /><span id="lblphone" style="color:Red"></span></td></tr>
                     <tr>
                        <td class="tdside" style=" width:100px; text-align:center;">
                  
                            是否审核:</td><td class="tdside"><input id="yes" name="yes" type="checkbox"  style=" width:20px" value="true"<%=Com.CMS263.Util.StringUtil.GetBool(guest.IsChecked)?"checked":"" %>/>是
                                </td></tr>
                    <tr>
                        <td class="tdside" style=" width:100px; text-align:center;">
                  
                     余&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 额:</td><td class="tdside">￥<input id="banance" name="banance" type="text" readonly="readonly" style=" width:50px;" value="<%= guest.Balance %>" ><span id="lblbanance" style="color:Red"></span></td></tr>
                 
                      <tr>
                 <td class="tdside" style=" width:100px; text-align:center;">
                  
                    地&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;址  :</td><td class="tdside"><input id="address"  type="text" name="address" value="<%=guest.Address%>" /><span id="addressSpan" style="color:Red"></span></td>
            </tr>
                     <tr><td colspan="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                         <asp:Button ID="Button1" runat="server" Text="修改" Width="50px"  
                             OnClientClick=" return useredit();" onclick="Button1_Click"/>
                       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input type="reset" value="取消" id="cancel" onclick="history.go(-1)"  style="width:50px" /></td></tr>
        </table>
    </form>
</body>
</html>
